<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style/global.css" />
<link rel="stylesheet" type="text/css" href="style/admin.css" />
<link rel="stylesheet" type="text/css" href="style/tip.css" />
<title>用户管理</title>
</head>

<body>
	<div id="wrap">
    	<div id="public_head"></div>
        <div class="m_revise" id="revise">
           	<form action='' method='post'> 
	        	<table class="tableForm" width="0" border="0">
	              <tr><th  height="45">用户名：</th><td><input class="qf_text" name="name" type="text" value="<?php echo $userinfo['USER_NAME']?>"/>&nbsp;<font color='red'>*</font></td></tr>
	              <?php if(empty($id)){?>
	              <tr><th  height="45">密码：</th><td><input class="qf_text" name="pwd" type="text" />&nbsp;<font color='red'>*</font></td></tr>
	              <?php }?>
	              <tr><th  height="45">所属医院：</th><td>
	              		<select class="select" name="unit">
	              		<?php 
	              			if(is_array($allUnit) && count($allUnit)>0){
	              				foreach ($allUnit as $k=>$v){
	              		?>
	              			<option value='<?php echo $k?>' <?php if(!empty($userinfo['UNIT_ID'])){echo $userinfo['UNIT_ID']==$k?' selected ':'';}else{echo $k==$unit_one?'selected':'';}?>><?php echo $v?></option>
	              		<?php
								}
	              			}else{
	              				echo "<option value='0'>暂时还没有添加医院</option>";
	              			}
	              		?>
	              		</select>&nbsp;<font color='red'>*</font>
	              		科室：
	              		<select class="select selectdep" name="dep" id="dep_<?php echo $unit_one;?>">
	              		<?php 
	              			if(is_array($alldep) && count($alldep)>0){
	              				foreach ($alldep as $k=>$v){
	              		?>
	              				<option value='<?php echo $k?>' <?php if($userinfo['DEP_NO']==$k) echo ' selected '?>><?php echo $v?></option>
	              		<?php
								}
	              			}else{
	              				echo "<option value='0'>暂时还没有添加科室</option>";
	              			}
	              		?>
	              		</select>
	              		
	              </td></tr>
	              <tr><th height="45">真实姓名：</th><td><input class="qf_text" name="realname" type="text"  value="<?php echo $userinfo['TRUE_NAME']?>"/></td></tr>
	              <tr><th height="45">工号：</th><td><input class="qf_text" name="code"  value="<?php echo $userinfo['DOC_NO']?>" id='workcode' type="text" /></td></tr>
	              <tr><th height="45">用户组</th><td>&nbsp;<font color='red'>*</font>&nbsp;
	              		<select class="select selectgroup" name="group" id="group_<?php echo $unit_one;?>">
	              		<?php 
	              			if(is_array($groups) && count($groups)>0){
	              				foreach ($groups as $k=>$v){
	              		?>
	              			<option value='<?php echo $k?>' <?php if($k==$userinfo['ROLE_ID'])echo ' selected '?>><?php echo $v?></option>
	              		<?php
								}
	              			}else{
	              				echo "<option value='0'>暂时还没有添加角色组</option>";
	              			}
	              		?>
	              		</select>
	              </td></tr>
	              <tr><th height="45"></th><td><input class="btn_save" name="add_user" type="submit" value=""/> <input class="btn_gray" name="" type="button" value="取 消" onclick="history.back();"/></td></tr>
	            </table>
            </form>
        </div>
    </div>
</body>
</html>
<script src="/js/xheditor/jquery/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="/js/boot.js" type="text/javascript"></script>
<script src="/js/tip.js" type="text/javascript"></script>
<script src="/js/checkform.js" type="text/javascript"></script>
<script src="/js/add_public_head.js" type="text/javascript"></script>
<script>
//var key = $('form').serialize();
$('input:submit.btn_save').click(function(){
		if($('input[name="name"]').val() == ''){
			alert('请正确输入用户名')
			return false;
		}
		if($('input[name="pwd"]').val() == '' || $('input[name="pwd"]').val().length<6){
			alert('请正确输入密码，必须大于6位')
			return false;
		}
});
$('select[name="unit"]').change(function(){
	var t = this;
	$('.selectdep').hide();
	$('.selectdep').attr('name','')
	$('.selectgroup').hide();
	$('.selectgroup').attr('name','')
	if($('#dep_'+$(this).val()).length>0){
		$('#dep_'+$(this).val()).show();
		$('#dep_'+$(this).val()).attr('name','tep');
		$('#group_'+$(this).val()).show();
		$('#group_'+$(this).val()).attr('name','group');
	}else{
		$.ajax({
			url:'/index.php?c=user&a=getdep&id='+$(t).val(),
			type:'get',
			dataType:'json',
			success:function(de){
				if(de){
					$(t).parent().append('<select class="select selectdep" name="dep" id="dep_'+$(t).val()+'">')
					$('.selectgroup').parent().append('<select class="select selectgroup" name="group" id="group_'+$(t).val()+'">')
					for(var i=0;i<de.dep.length;i++){
						$('#dep_'+$(t).val()).append('<option value="'+de.dep[i].DID+'">'+de.dep[i].DN+'</option>')
					}
					for(var i=0;i<de.group.length;i++){
						$('#group_'+$(t).val()).append('<option value="'+de.group[i].RID+'">'+de.group[i].RN+'</option>')
					}
					$(t).parent().append('</select>')
					$('.selectgroup').parent().append('</select>')
				}
			}
		})
	}
})
</script>